package docmanager.operation.documentos;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import docmanager.business.objects.Sector;
import docmanager.business.objects.TipoDocumento;
import docmanager.db.ConnectionPool;

import bf.operation.Operation;
import bf.operation.OperationException;

public class OpConsultarDocumento1 extends Operation {


	
/*	
	@Override
	public Map execute(HttpServletRequest request) throws OperationException {
		Map m = new HashMap();
		// Primero, obtenemos una lista de los tipos de documentos.
		try {
			Connection conn = ConnectionPool.getConnection();
			List<TipoDocumento> l = TipoDocumento.obtenerTodosTipos(conn);
			ConnectionPool.closeConn(conn);
			m.put("tipos", l);
			m.put("accion", "consulta");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw new OperationException();
		}
		return m;
	}
*/
	
	@Override
	public Map execute(HttpServletRequest request) throws OperationException {
		Map m = new HashMap();
		// Primero, obtenemos una lista de los tipos de documentos.
		try {
			Connection conn = ConnectionPool.getConnection();
			List<Sector> l = Sector.obtenerTodosLosSectores(conn);
			ConnectionPool.closeConn(conn);
			m.put("sectores", l);
			m.put("accion", "consulta");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw new OperationException();
		}
		return m;
	}
	
	@Override
	public String getReturnURL() {
		// TODO Auto-generated method stub
		return "Documentos/ListarSecciones.jsp";
	}

}
